WIDTH = 300
HEIGHT = 300

BACK_COLOR = (0, 0, 127)
CIRCLE_COLOR = (0, 200, 0)

x, y = 50, 100
spd_x, spd_y = 3, 1
r = 50
def on_key_down(key):
    if key == keys.ESCAPE:
        quit() 
        
def on_mouse_down(pos):
    print("mouse_down", pos)
    
def on_mouse_up(pos):
    print("mouse_up", pos)
    
def draw_circle(x, y, r):
    screen.draw.filled_circle((x, y), r, CIRCLE_COLOR)
    return 1
    
def update():
    global x, y
    global spd_x, spd_y
    x += spd_x
    y += spd_y
    if x + r > WIDTH or x - r < 0:
         spd_x *= -1
    if y + r > HEIGHT or y - r < 0:
         spd_y *= -1
        
def draw():
    screen.clear()
    screen.fill(BACK_COLOR)
    draw_circle(x, y, r)

